<?php
declare (strict_types = 1);

namespace app\middleware;

use app\logic\User;

class checkAdmin
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     */
    public function handle($request, \Closure $next)
    {
        // 验证是否登录
        if (!(new User())->isLogin()) {
            // 判断是否安装
            if(!(new \app\logic\Install())->isInstall()) {
                return redirect((string) url('Install/index'));
            }
            return redirect((string) url('login/index'));
        }

        return $next($request);
    }
}
